package com.hbnu.iostream;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

/**
 * 需求：
 * 往指定磁盘文件写入内容，使用字符输出流
 *
 * @author kittychen
 * @date 2025-09-30 16:52
 */
public class WriterDemo01 {

    public static void main(String[] args) {
        String path = "E:" + File.separator + "2309" + File.separator + "writer.txt";

        File file = new File(path);

        Writer writer = null;

        try {
            writer = new FileWriter(file, true);

            String content = "\r\nhello world";

            writer.write(content);

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (writer != null) {
                    writer.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

}
